#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int coinChange(vector<int> &coins, int amount)
    {
        vector<int> dp(amount + 1, INT_MAX - 1);
        dp[0] = 0;
        for (int i = 0; i < (int)coins.size(); i++)
        {
            for (int j = coins[i]; j <= amount; j++)
            {
                dp[j] = min(dp[j], dp[j - coins[i]] + 1);
            }
        }
        if (amount != 0 && dp[amount] == INT_MAX - 1)
        {
            return -1;
        }
        return dp[amount];
    }
};

int main()
{
    vector<int> coins{1, 2, 5};
    Solution sol;
    cout << sol.coinChange(coins, 11) << endl;
    return 0;
}